// To parse this JSON data, do
//
//     final commonDetailModel = commonDetailModelFromJson(jsonString);

import 'dart:convert';

import 'package:jetour_line/models/jetour_line_detail.dart';

CommonDetailModel commonDetailModelFromJson(String str) => CommonDetailModel.fromJson(json.decode(str));

String commonDetailModelToJson(CommonDetailModel data) => json.encode(data.toJson());

class CommonDetailModel {
  CommonDetailModel({
    required this.id,
    required this.caption,
    required this.images,
     this.tag,
    required this.startProvince,
    required this.startCity,
    required this.endProvince,
    required this.endCity,
    required this.totalDay,
    required this.distance,
    required this.description,
    required this.nodeList,
    required this.otherData,
    required this.videos
  });

  int id;
  String caption;
  List<String> images;
  List<String>? tag;
  List<Videos> videos;
  var startProvince;
  var startCity;
  var endProvince;
  var endCity;
  int totalDay;
  String distance;
  String description;
  List<NodeList> nodeList;
  OtherData otherData;

  factory CommonDetailModel.fromJson(Map<String, dynamic> json) => CommonDetailModel(
    id: json["id"],
    caption: json["caption"],
    images: List<String>.from(json["images"].map((x) => x)),
    tag: json["tag"] == null?[]:List<String>.from(json["tag"].map((x) => x)),
    startProvince: json["startProvince"],
    startCity: json["startCity"],
    endProvince: json["endProvince"],
    endCity: json["endCity"],
    totalDay: json["totalDay"],
    distance: json["distance"],
    description: json["description"] == null?'': json["description"],
    nodeList: List<NodeList>.from(json["nodeList"].map((x) => NodeList.fromJson(x))),
    videos: List<Videos>.from(json["videos"].map((x) => Videos.fromJson(x))),
    otherData: OtherData.fromJson(json["otherData"]),
  );

  Map<String, dynamic> toJson() => {
    "id": id,
    "caption": caption,
    "images": List<dynamic>.from(images.map((x) => x)),
    "tag": List<dynamic>.from(tag!.map((x) => x)),
    "startProvince": startProvince,
    "startCity": startCity,
    "endProvince": endProvince,
    "endCity": endCity,
    "totalDay": totalDay,
    "distance": distance,
    "description": description,
    "nodeList": List<dynamic>.from(nodeList.map((x) => x.toJson())),
    "videos": List<dynamic>.from(videos.map((x) => x.toJson())),
    "otherData": otherData.toJson(),
  };
}
class NodeList {
  int dayId;
  String startCity;
  String endCity;
  int distance;
  String distanceText;
  List<Node> node;

  NodeList({
    required this.dayId,
    required this.startCity,
    required this.endCity,
    required this.distance,
    required this.distanceText,
    required this.node,
  });

  factory NodeList.fromJson(Map<String, dynamic> json) => NodeList(
    dayId: json["dayId"],
    startCity: json["startCity"],
    endCity: json["endCity"],
    distance: json["distance"],
    distanceText: json["distanceText"],
    node: List<Node>.from(json["node"].map((x) => Node.fromJson(x))),
  );

  Map<String, dynamic> toJson() => {
    "dayId": dayId,
    "startCity": startCity,
    "endCity": endCity,
    "distance": distance,
    "distanceText": distanceText,
    "node": List<dynamic>.from(node.map((x) => x.toJson())),
  };
}

class Node {
  int nodeId;
  String caption;
  String logo;
  List<String> images;
  String provinceName;
  String cityName;
  String address;
  double lng;
  double lat;
  int distance;
  dynamic description;

  Node({
    required this.nodeId,
    required this.caption,
    required this.logo,
    required this.images,
    required this.provinceName,
    required this.cityName,
    required this.address,
    required this.lng,
    required this.lat,
    required this.distance,
    this.description,
  });

  factory Node.fromJson(Map<String, dynamic> json) => Node(
    nodeId: json["nodeId"],
    caption: json["caption"],
    logo: json["logo"],
    images: List<String>.from(json["images"].map((x) => x)),
    provinceName: json["provinceName"],
    cityName: json["cityName"],
    address: json["address"],
    lng: json["lng"]?.toDouble(),
    lat: json["lat"]?.toDouble(),
    distance: json["distance"],
    description: json["description"],
  );

  Map<String, dynamic> toJson() => {
    "nodeId": nodeId,
    "caption": caption,
    "logo": logo,
    "images": List<dynamic>.from(images.map((x) => x)),
    "provinceName": provinceName,
    "cityName": cityName,
    "address": address,
    "lng": lng,
    "lat": lat,
    "distance": distance,
    "description": description,
  };
}
class OtherData {
  OtherData({
    required this.fav,
  });

  bool fav;

  factory OtherData.fromJson(Map<String, dynamic> json) => OtherData(
    fav: json["fav"],
  );

  Map<String, dynamic> toJson() => {
    "fav": fav,
  };
}
